#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000000 + 7;
map < int, int > h, pd[100005];
long long ans, sum, a[100005];
int n, m, k, x, y, tot;
long long mi(long long x, int y) {
    long long z = x; 
    y--;
    while(y) {
        if(y & 1) (z *= x) %= mo;
        (x *= x) %= mo;
        y >>= 1;
    }
    return z;
}
int main() {
    freopen("easy.in", "r",stdin);
    freopen("easy.out", "w",stdout);
    scanf("%d%d%d", &n, &m, &k);
    sum = (long long) n * (n + 1) / 2 % mo;
    for(int i = 1; i <= k; i++) {
        scanf("%d%d", &x, &y);
        if (!h[x]) h[x] = ++tot;
		x = h[x];
        if (pd[x][y]) continue;
		pd[x][y] = 1;
        (a[x] += (long long) mo - y) %= mo;
    }ans = mi(sum, m - tot);
    for(int i = 1;i <= tot; i++) (ans *= a[i] + sum) %= mo;
    printf("%lld", ans);
}
